﻿package com.eitb.programas.ticker{
	import flash.display.*;
	import flash.text.*;
	import flash.events.*;
	import flash.media.*;
	import flash.net.*;
	import flash.utils.*;
	import flash.text.*;
	import flash.filters.*;
	
	import com.eitb.cargadores.*;
	import com.eitb.reproductores.*;
	
	import com.eitb.programas.ticker.entidades.*;


	import fl.transitions.*;
	import fl.transitions.easing.*;
 


	public class DialogoTicker extends Sprite implements IVistaTicker {
		private var cTicker:IControladorTicker;
		
		public function DialogoTicker():void {
			this.mascara.visible = false;
			this.buttonMode = true;
			this.mouseChildren = false;
		}

		// INIT COMPONENTES
		public function initControlador(cTicker:IControladorTicker):void {
			trace("initControlador");
			this.cTicker=cTicker;
		}
		// INIT COMPONENTES

		// INIT PROPERTIES
		public function initFormato(formato:Object):void {
			this.stage.align= formato.stageAlign;
			this.stage.scaleMode =formato.scaleMode;
			
			this.stage.stageWidth = formato.width;
			this.stage.stageHeight = formato.height;
			
			this.width = formato.width;
			this.height = formato.height;
		}
		
		public function initTexto(formato:Object, estilo:Object) {
			trace("initTexto");
	        var styleSheet:StyleSheet = new StyleSheet();
            styleSheet.setStyle(".estilo", estilo);
			
			this.texto.x = formato.texto.x; 
			this.texto.y = formato.texto.y; 
			this.texto.width = formato.texto.width; 
			this.texto.height = formato.texto.height; 
			
			this.texto.styleSheet = styleSheet;
//			this.texto.filters = new Array(new BlurFilter(2, 2, BitmapFilterQuality.HIGH));

			this.mascara.x = formato.mascara.x; 
			this.mascara.y = formato.mascara.y; 
			this.mascara.width = formato.mascara.width; 
			this.mascara.height = formato.mascara.height; 
		}
		
		// INIT PROPERTIES

		// INIT VARIABLES
		public function initEvents():void {
			trace("initEventos");
			
			this.addEventListener(MouseEvent.CLICK, this.cTicker.onMouseClick);
			this.addEventListener(MouseEvent.DOUBLE_CLICK, this.cTicker.onMouseDoubleClick);
		}
		
		public function initNextNewTimerEvent(timer:Timer):void {
			timer.addEventListener(TimerEvent.TIMER, this.cTicker.onTimerNext);
		}
		// INIT VARIABLES
		
		// IVistaTicker
		public function setVisible(visible:Boolean):void {
			trace("mostrando");
			this.visible=visible;
		}
		
		public function transition(transition:Object):void {
			trace("haciendo transicion");
			this.mascara.visible = true;
			TransitionManager.start(this.mascara, transition)
		}
		
		public function setNoticia(noticia:Noticia):void {
			trace("poniendoNoticia");
			this.texto.htmlText = "<span class='estilo'>".concat(noticia.getTitle()).concat("</span>");
		}
		
		// function addChild por extension
		
		// IVistaTicker
	}
}